package main

import (
	"fmt"
	"gitee.com/fierce_wolf/go-fox-edge-common/commUtil/Routine"
	"math/rand"
	"time"
)

func worker(id int64) {
	// 模拟工作时间
	workTime := time.Duration(rand.Intn(5)+1) * time.Second
	time.Sleep(workTime)

	fmt.Printf("工作协程 %d 结束 after %v\n", id, workTime)
}

func main() {
	engine := Routine.NewWorkerEngine()

	engine.Run(10, worker)
	time.Sleep(10 * time.Second)
	engine.Close()
	time.Sleep(1000 * time.Second)
}
